package com.frikinet.lifeguard.util;

import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;

import org.apache.commons.lang.StringUtils;

public class WeekNames extends ArrayList<String>
{
	private static final long serialVersionUID = 1L;

	public WeekNames(String format)
	{
		super();
		SimpleDateFormat sdf = new SimpleDateFormat(format, getSymbols());
		Calendar date = Calendar.getInstance();
		date.set(Calendar.DAY_OF_WEEK, date.getFirstDayOfWeek());
		for(int i=1;i<=7;i++)
		{
			add(StringUtils.capitalize(sdf.format(date.getTime())));
			date.add(Calendar.DATE, 1);
		}
	}
	
	private DateFormatSymbols getSymbols()
	{
		DateFormatSymbols symbols = new DateFormatSymbols();
		Locale locale = Locale.getDefault();
		if(locale.getLanguage().equals("es"))
		{
			symbols.setShortWeekdays(new String[]{" ", "D", "L", "M", "X", "J", "V", "S"});
		}
		else if(locale.getLanguage().equals("en"))
		{
			symbols.setShortWeekdays(new String[]{" ", "Su", "Mo", "Tu", "Wd", "Th", "Fr", "Sa"});
		}
		return symbols;
	}
}
